<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"import="base.*,pojo.*,service.*,java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">

#box{
	border: 10px groove #CDC9C9;
	height: 500px;
	width: 500px;
	margin-left:auto;
	margin-right:auto;
}
#b1{
	height: 50px;
	width: 510px;
	margin-top: 35px;
}

#s{
   height:40px;
   width:490px;
   margin-bottom:5px;
   }
  body{
	margin:0;
	padding:20px;
	background-image:url("images/innerBJ.jpg");
	background-repeat:no-repeat;
	font:80% Arial, Helvetica, sans-serif;
	color:#555;
	line-height:100%;
}  
</style>

<script type="text/javascript" src="jquery/jquery-1.6.1.js"></script>
<script type="text/javascript" src="jquery/jquery.validate.min.js"></script>
<script> 
$(function(){
	$("#add").click(function(){
            var name=$("#Name").val();
			var type=$("#Type").val();
			var quality=$("#Quality").val();
			var price=$("#Price").val();
			var pic=$("#pic").val();
	if(name==0){
        alert("请输入菜品名");
        $("#Name").focus();
        return false;
    }
   
   else if(type==0){
    alert("请选择菜品类型");
       return false;
    }
    else if(pic==""){
    alert("请上传图片");
    return false；
    
    }
    
    else if(quality==""){
    alert("请输入菜品构成")
    $("#Quality").focus();
     return false;
     }
       else if(price==""){
    alert("请输入菜品价格")
    $("#Quality").focus();
     return false;
     }
    else{$("#form1").submit()}
    
	})
})
</script>
<script type="text/javascript">
$(function(){

	$("#upload").click(function(){
		$.ajax({
		
			type:"get",
			dataType:"json",
			url:"action/upload.jsp",
			success:function(data){
			if(data.success){
				$("#pic").val(data.path);
			}				
			}
		
		});

	})
	
})



</script>

</head>


<body>
<%
request.setCharacterEncoding("UTF-8");
DishesService m=new DishesService();
int id = Integer.valueOf(request.getParameter("id"));
dishes de=m.getDishesDetail(id);
%>
	
	
		<div id="box" >
		  
			 <form id="form1" method="post" action="action/dishes_inforupdate.jsp">
								<input type="hidden" name="Id" value="<%=de.getId() %>">
									
									<div class="field" id="s"><label>菜品编号:</label><%=de.getId() %></div>
									<div class="field" id="s"><label>菜品名称:</label><input id="Name" name="Name" value="<%=de.getName() %>"></div>
									<div class="field" id="s"><label>所属种类:</label><select style="width:150px;"  id="Type" name="Type" >
									<%
	                           DishesService ds = new DishesService();	
	                           List<dishesType> list = ds.getDishesType();	

	                           for(dishesType d:list){
		                       if(d.getId()==de.getType())
			                   out.print("<option value='"+d.getId()+"' selected='selected'>"+d.getName()+"</option>");
		                         else
			                     out.print("<option value='"+d.getId()+"'>"+d.getName()+"</option>");
	                           } %>
	
	                                    </select>
									
									
									
									
									
									</div>
									<div class="field" style="marggin-bottom:20px;" id="s"><label>菜品材料:</label><textarea id="Qulity" name="Quality"><%=de.getQuality() %></textarea></div>
									<br>
									<br>
									<div class="field" id="s"><label>菜品图片:</label><input name="Picture"  id="pic" value="<%=de.getPicture() %>">&nbsp;&nbsp;&nbsp;&nbsp;<a style="text-decoration:none;" href="javascript:;" id="upload">上传</a></div>
									<div class="field" id="s"><label>菜品介绍:</label><textarea name="Detail"><%=de.getDetail() %></textarea></div>
									<br>
									<br>
									<br>
									<div class="field" id="s"><label>打折情况:</label>
				<select name="Sale" style="width:150px;">
			    <option value=10 >---请选择---</option>
			    <option value=1>1折</option>
			    <option value=2>2折</option>
			    <option value=3>3折</option>
			    <option value=4>4折</option>
			    <option value=5>5折</option>
			    <option value=6>6折</option>
			    <option value=7>7折</option>
			    <option value=8>8折</option>
			    <option value=9>9折</option>
			    </select>
									
									
									</div>
									<div class="field" id="s"><label>菜品价格:</label><input name="Price"  id="Price" value="<%=de.getPrice() %>"></div>
									<br/>
									<input id="add" type="submit" value="保存">&nbsp;&nbsp;&nbsp;<input  type="reset" value="重置">
									
									
								</form>
			  <br />
			
			
			  
			</div>
		

		
		
    

</body>
</html>
